<template>
     <div id="commitSwitch">
       <div class="jx-content part2">
            <div class="commution-center">
                <!-- <i class="iconfont icon-tubiaozhizuomoban why"></i> -->
                <img src="../../../assets/images/commit.png" class="why"/>
            </div>
           <div class="centerSwitch">
              <span class="centerSwitch-title">开启学生端问题交流：</span>
              <span class="dialog-content">
                   <el-radio-group v-model="swutchradio">
                        <el-radio  :label="true">是</el-radio>
                        <el-radio  :label="false">否</el-radio>
                   </el-radio-group>
              </span>
              <div class="btn-submit">
               <button class="button-style" @click="save">保 存</button>
              </div>
           </div>
         
        </div>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                swutchradio:'',
                //课程id
                courseId:''
            }
        },
        created() {
            this.courseId = this.$localstorage.getLocalStorage('setCourseId')
            this.init()
        },
        methods: {
            init() {
                let self = this
                self.$http.get('/tes/problemCommunication/getProblemSwitch/'+self.courseId).then((response) => {  // 1 换成courseId 课程id
                    let res = response.data
                    if(res.code == '200') {
                     self.swutchradio =res.data.pcSwitch
                    }else{
                        self.$message.error(res.message)
                    }
                })
            },
            //保存
            save(){
                let self = this
                self.$http.post('/tes/problemCommunication/controlSwitch',{  // 1 换成courseId 课程id
                    pcSwitch: self.swutchradio,
                    courseId:self.courseId,
                }).then((response) => {
                    let res = response.data
                    if(res.code == '200') {
                        self.$message({
                            message: '保存成功',
                            type: 'success'
                        })
                        self.init()
                    }else{
                        self.$message.error(res.message)
                    }
                })
            }
        }
    
    }
</script>

<style scoped lang="scss">
@import "./../../../styles/layout/color_variables";
    .part2{
         margin: 0px
    }
 #commitSwitch {
    width: $width;
    margin: 0px auto;
    color: #727272;
      .commution-center{
          width: 200px;
          margin: 30px auto;
          padding-top: 90px
      }
      .why{
          font-size: 160px;
          color: #ededed;
      }
      .commution-question{
          line-height: 50px;
          font-size: 16px;
      }
    .centerSwitch{
        text-align: center;
        padding-bottom: 100px;
        .centerSwitch-title{
            font-size: $fs16
        }
        .btn-submit{
            margin-top: 80px;
        }
    }
    
  }
</style>